package com.example.task;

import com.example.websocket.DeviceWebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class DeviceDataScheduler {

    @Autowired
    private DeviceWebSocketHandler deviceWebSocketHandler;

    // 每5秒推送一次设备状态更新
    @Scheduled(fixedRate = 5000)
    public void pushDeviceState() {
        deviceWebSocketHandler.broadcastDeviceState();
    }

    // 每5秒推送一次设备属性更新
    @Scheduled(fixedRate = 5000)
    public void pushDeviceAttribute() {
        deviceWebSocketHandler.broadcastDeviceAttribute();
    }
}
